In a cloud environment, resource allocation (mapping) refers to that a requirement application for a virtual resource is made, and physical resource scheduling and allocation are performed, according to existing topology conditions of a physical resource and a resource pool, on the virtual resource needed by a virtual machine, and then the virtual resource is deployed according to a result of the resource scheduling. The virtual machine refers to a complete computer system that has a complete hardware system function and runs in a completely isolated environment by means of software simulation. The virtual resource may further include a virtual central processing unit (vCPU), a virtual memory (vMEM), a virtual input/output (vIO) device, and the like. In addition, the physical resource and the resource pool are generally provided in a form of a server or a server cluster. A server (cluster) has multiple processor nodes, where the processor node is a system that includes a physical central processing unit (CPU), and a physical memory and a physical input/output (IO) device that are directly connected to a pin of the physical CPU.
In other approaches, resources are generally allocated according to different virtual resource constraints. For example, a resource allocation method may be implemented in the following two manners.
Manner 1: A resource is allocated in a static random allocation manner. For example, during allocation of a resource to a virtual machine, a physical processor, a physical IO, and a physical memory that are not occupied are randomly selected and allocated to the virtual machine.
Manner 2: A resource is allocated in real time according to a load status of a physical processor. Further, the physical processor is dynamically allocated in real time to virtual processors of different virtual machines, according to a consumption status of each physical core (that is, a core in the physical processor, which is referred to as an independent computing unit in each physical processor) or hyperthread of the physical processor in order to achieve basically balanced consumption of all physical cores or hyperthreads of the physical processor. For example, if the physical processor has eight physical cores, one virtual processor of the virtual machines can be dynamically and periodically deployed on the eight physical cores, and one physical core is occupied in a period of time, and another physical core is occupied in a next period of time such that load of all the physical cores of the physical processor is basically balanced. However, the vMEM and the vIO are generally allocated in a random allocation manner.
In the foregoing two manners, a problem of a long data transmission delay exists between the virtual processor, the vMEM, and the vIO that are of the virtual machine, which increases consumption of the physical processor and reduces performance of the virtual machine.